import { ratedApi } from "../utils/api";

const ratedModule = {
  namespaced: true,
  state: {
    // 最受欢迎数据
    ratedList: [],
  },
  mutations: {
    // 改变最受欢迎数据
    getRated(state, payload) {
      state.ratedList = payload.result;
    },
  },
  actions: {
    // 最受欢迎列表数据请求
    getRatedAsync({ commit }) {
      return new Promise((resolve) => {
        ratedApi().then((res) => {
          commit("getRated", res);
          resolve();
        });
      });
    },
  },
};

export default ratedModule;
